<template>
	<view class="innerContain">
         <view class="top-content"></view>
         <view class='topradio'>
		<view class="top">
			<card :data="data" :cartcount='cartcount'/>
		</view>
		<!-- <view class="gap">
			
		</view> -->
		<view class="childborder">
			<u-form :model="form" ref="uForm" :error-type="errorType">
					<u-form-item  class="selectone"  style="padding:0rpx 0rpx 0rpx 0rpx;margin-top:-14rpx;" label="温度" prop="detail">
						<u-input  style="right:32rpx" type="text" placeholder="请输入温度"  v-model="form.detail" />
					</u-form-item>
				</u-form>
		</view>
		<view class="footer">
			<u-button class='btn' @click='returnHandle' type="primary" :ripple="true" ripple-bg-color="#32afff">保存</u-button>
		</view>
	</view>
	</view>
</template>

<script>
import card from "@/components/innerCard/innerCard.vue";
import {
  pointCheckDeviceDetail,
  pointCheckDeviceDetailEdit,
  pointCheckDescriptionAdd,
  pointCheckeDviceDetailList,
  pointCheckDeviceDetailAdd,
  pointCheckDescriptionEdit,
  pointCheckDeviceDetai
} from "@/api/index.js";
export default {
  components: {
    card
  },
  onLoad(val) {
    this.cartcount = getApp().globalData.uname
    this.state = val.Tdata;
     this.tf = val.tf;
    this.taskDeviceId = val.taskDeviceId;
    this.Tdata=val.Tdata
     this.getList();
  },
  onShow() {
   
  },
  data() {
    return {
      form: {},
      errorType: ['message'],
      rules: {
        detail: [
          {
            required: true,
            message: "请输入温度",
            trigger: "blur,change",
          }
        ]
      },
      data: {
        name: "工况",
        time: "2021-8-19 12:02",
        number: "01",
        position: "北京",
        normal: "2",
        error: "2",
        num: "1",
        isCheck: true,
        people: "王五"
      }
    };
  },
  methods: {
    getList() {
       uni.showLoading({
        title: "加载中"
      });
if(this.tf){
        this.state = this.taskDeviceId;

      pointCheckDeviceDetai(this.state).then(res => {
        // res.data["工况"].pointCheckDeviceDetails.forEach(item => {
        //   if (item.item == "温度") {
             this.id = res.data.id;
          this.form = res.data;
             if(!this.form.detail){
                this.form.detail=this.form.status
              }else {
	  this.form.detail=this.form.detail
              }
        //   }
        // });
          uni.hideLoading();

      });
}else {
        pointCheckDeviceDetail(this.state).then(res => {
        res.data["工况"].pointCheckDeviceDetails.forEach(item => {
          if (item.item == "温度") {
            this.id = item.id;
            for (let i in item) {
              if (!item[i]) {
                delete item[i];
              }
            }
            this.form = item;
             if(!this.form.detail){
                this.form.detail=this.form.status
              }else {
	  this.form.detail=this.form.detail
              }
          }
        });
          uni.hideLoading();

      });
}
    },
    returnHandle() {
      this.$refs.uForm.validate(valid => {
        if (valid) {
          const data = {
            id: String(this.id),
            taskDeviceId: String(this.state),
            type: "工况",
            item: "温度",
            detail:this.form.detail,
            status:'正常'
          };
          if (!data.id | (data.id == "undefined")) {
            delete data["id"];
          }
           if(this.tf){
        data.taskDeviceId=String(this.Tdata)
      }
            pointCheckDeviceDetailAdd(data).then(res => {
 uni.navigateBack({
                delta: 1
              })
            })
        
        } else {
          console.log("验证失败");
        }
      });
    },
    onReady() {
      this.$refs.uForm.setRules(this.rules);
    }
  }
};
</script>

<style lang="scss" scoped>

.innerContain {
  height: 100%;
  position: relative;
  background-color: white;
}
.top-content {
  height: 160rpx;
  background: linear-gradient(to left, #1040be, #026dff);
}
.topradio {
    height: calc(100% - 200rpx);
   overflow-y: auto;
  position: absolute;
  background-color: white;
  // padding: 30rpx;
  width: 100%;
  top: 50rpx;
  border-radius: 40rpx 40rpx 0 0;
  // position: absolute;
  // width: 100%;
  // top: 0rpx;
  // left: 0rpx;
  // background-color: white;
  // border-radius: 40rpx 40rpx 0 0;
}
.top {
  padding: 16rpx;
  /* box-shadow: 20px -77px 0px 19px #c6c6ca; */
  box-shadow: 4rpx 4rpx 20rpx #e5e1e1;
  margin: 24rpx;
  border-radius: 32rpx;
}
.childborder {
  padding: 34rpx;
  margin: 24rpx;

  box-shadow: 0px 6px 33px #e5e1e1;
  border-radius: 32rpx;
}
.trueorfalse {
  margin-right: 20rpx;
  top: 6rpx;
}
.red1 {
  padding: 25rpx 0rpx;
}
.footer {
  background-color:transparent
  
}
.btn {
  background: linear-gradient(-34deg, #1040be, #026dff);
  width:544rpx;
  height: 91rpx;
  font-size: 36rpx;
  font-weight: 500;
  color: #ffffff;
  border-radius:46rpx;
}
/deep/ .u-form-item--left__content__label{
  font-size: 33rpx
}
/deep/ .u-input__input{
  // color:
}

.co{
		color: red;
	}
/deep/ .u-input__input {
  text-align: right
  }
 /deep/ .u-form-item__message {
 text-align: right;
margin-right:32rpx
  }
 .borderbottom:after {
  border-bottom-width: 0px !important
 }
 /deep/ .input1>.u-input__input>.uni-input-wrapper>.uni-input-input {
   display: none !important;
  //  color:red !important
 }
/deep/ .selectone:after { 
    border-top-width: 0px !important;
    border-bottom-width: 0px !important;
}
.selectone1:after {
      border-top-width: 1px !important;
}
</style>
